import {createRouter, createWebHashHistory} from 'vue-router'

const routes = [
    {
        path: '/',
        name: 'login',
        component: () => import('@/views/login/index.vue'),
        meta: { title: '登录', noAuth: true } , 
        alias: '/login' // 同时支持 / 和 /login 访问登录页
    },
]

const router = createRouter({
    history: createWebHashHistory(), 
    routes,
    // scrollBehavior(to, from, savedPosition) {  // 添加滚动行为
    //   return savedPosition || { top: 0 }
    // }
})
// 全局路由守卫示例
router.beforeEach((to, from, next) => {
    console.log(`当前路由：${to.path} - ${from.path}`)
    next()
})

export default router